<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../app'));
    
// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

$paths = implode(PATH_SEPARATOR,
                    array (
                    dirname(realpath(''))."/library",
                    dirname(realpath(''))."/app",
                    dirname(realpath(''))."/app/models",       
                    ));

// Пути по которым происходит поиск подключаемых файлов, это папка библиотек, моделей и системных файлов
set_include_path($paths);

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));


require 'autoload.php';
require 'Zend/Loader.php';
require_once 'Zend/Application.php';  

// Create application, bootstrap, and run
/*
$application = new Zend_Application(APPLICATION_ENV, 'config/config.ini');
$application->bootstrap()->run();
//*/
///*
$ZendConfig = new Zend_Config_Ini('config/config.ini');
$ZendDb= new Zend_Db_Adapter_Pdo_Mysql($ZendConfig->database);
$ZendDb->exec('SET NAMES utf8');
Zend_Registry::set('dbAdapter',$ZendDb);
Zend_Db_Table_Abstract::setDefaultAdapter($ZendDb);
/*
$ZendAuth = Zend_Auth::getInstance();
$ZendAuth->setStorage(new Zend_Auth_Storage_Session());
/*
$authAdapter = new Zend_Auth_Adapter_DbTable($ZendDb,'ez_users','name','password','MD5');
$authAdapter->setIdentity($_REQUEST['login_name']);
$authAdapter->setCredential($_REQUEST['login_password']);
$authAdapter->setCredentialTreatment('MD5(?)');
$ZendAuth->authenticate($authAdapter);
//*/

$ZendFront = Zend_Controller_Front::getInstance();
$ZendFront->throwExceptions(true);
$ZendFront->setControllerDirectory(APPLICATION_PATH."/controllers");
Zend_Layout::startMvc(array('layoutPath'=>'../app/layouts/scripts'));

//$ZendFront->setParams();
$ZendFront->dispatch();









